/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Controllers;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author BENSON
 */
public class ControllerAddPatient {
      /**
     * variable and views declarations
     */
    Views.AddPatient addPatient;
    Model.MainModel model;
    private ActionListener actionListener;
    
    
    /**
     * constructor for instantiating declared views
     */
    public ControllerAddPatient( ){
        addPatient = new Views.AddPatient();
        addPatient.setVisible(true);
        model= new Model.MainModel();
                          
    }     
    
     /**
      * Method to add actionListener to a clicked button
      */
    
     public void control(){        
        actionListener = new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent actionEvent) {  
                  if(actionEvent.getSource()==addPatient.getSaveBtn()){
                        model.addPatients(addPatient);
                  }
                  if(actionEvent.getSource()==addPatient.getCloseBtn()){
                  addPatient.setVisible(false);
                  
                  }
               }
              
        };                
        addPatient.getSaveBtn().addActionListener(actionListener);
        addPatient.getCloseBtn().addActionListener(actionListener);
        
    }
    
}
